<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS布局-transform</title>
    <link rel="stylesheet" href="./center.css"> 
    <style>
        .parent {
            width: 100px;
            height: 100px;
            background: yellow;
            border: 1px solid #000;
            position: relative;
        }
        .children {
            background-color: red;
            z-index: 1;
            width: 50px;
            height: 10px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
    </style>  
</head>
<body>
    <div class="parent">
        <div class="children"></div>
    </div>
</body>
</html>